<?php defined('SYSPATH') or die('No direct script access.');

class Model_Reserva extends ORM {

	public $_belongs_to = array(
		'responsavel' => array(
			'model' => 'responsavel',
			'foreign_key' => 'responsavel_id'
		),
		'usuario' => array(
			'model' => 'usuario',
			'foreign_key' => 'usuario_id'
		),
	);
	
	public $_has_one = array();
	
	public $_has_many = array(
		'periodos' => array(
			'model' => 'periodo',
			'foreign_key' => 'reserva_id'
		),
	);
	
	public $_table_name = 'reservas';
	public $_primary_key = 'id';
	
	
	
	public static function reservasDeHoje()
	{
		$hoje = strtotime();
		
		$periodos = ORM::factory('periodo')->where('inicio', '<=', $hoje)->find_all();
	}
	/*
	public function rules()
	{
		return array(
			'usuario' => array(
				array('not_empty'),
			),
			'senha' => array(
				array('not_empty'),
			),
		);
	}
	*/
	
} // End Reserva
